package com.hziee.cosmanage.manageandhr.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hziee.cosmanage.manageandhr.entity.CharacterEntity;
import com.hziee.cosmanage.manageandhr.service.CharacterService;
import com.hziee.common.utils.PageUtils;
import com.hziee.common.utils.R;



/**
 * 公司角色表
 *
 * @author yb
 * @email yangbin@gmail.com
 * @date 2021-02-10 12:51:47
 */
@RestController
@RequestMapping("manageandhr/character")
public class CharacterController {
    @Autowired
    private CharacterService characterService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("manageandhr:character:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = characterService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{companyCharacterId}")
    //@RequiresPermissions("manageandhr:character:info")
    public R info(@PathVariable("companyCharacterId") Integer companyCharacterId){
		CharacterEntity character = characterService.getById(companyCharacterId);

        return R.ok().put("character", character);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("manageandhr:character:save")
    public R save(@RequestBody CharacterEntity character){
		characterService.save(character);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("manageandhr:character:update")
    public R update(@RequestBody CharacterEntity character){
		characterService.updateById(character);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("manageandhr:character:delete")
    public R delete(@RequestBody Integer[] companyCharacterIds){
		characterService.removeByIds(Arrays.asList(companyCharacterIds));

        return R.ok();
    }

}
